Skip to main content
Version: 1.2.0

Text to Image API

Text to Image API Documentation

Version: 1.2.0

Paths

Healthcheck API

/text-to-image/api/v1/healthz/

  • Method: GET
  • Summary: Health Check
  • Description: Return Health Status.
  • Responses:
    • 200:
      • Description: Successful Response
      • Content-Type: application/json

Text Validation API

/text-to-image/api/v1/text_validation

  • Method: POST
  • Summary: Validate the provided input text.
  • Description: The provided input text is validated to ensure it is suitable for generating an image. It checks if the input text can be interpreted and processed effectively to produce a corresponding image.

Request Payload:

TypeParameterDescriptionData TypeIs Optional
Form Datainput_typeValidates the Input textStringNo

Sample Code :

import requests

url = "https://api-genai-dev.learningmate.co/text-to-image/api/v1/text_validation"
token = "your_token_here"

headers = {
"accept": "application/json",
"Authorization": f"Bearer {token}",
"Content-Type": "application/x-www-form-urlencoded",
}

data = {
"input_text": """A paper craft art depicting a girl giving her cat a gentle hug. Both sit amidst potted plants, with the cat purring contentedly while the girl smiles. The scene is adorned with handcrafted paper flowers and leaves.""",
}

response = requests.post(url, headers=headers, data=data)

Example Response:

{
"status_code": 200,
"message": "SUCCESS::Text Validation generated successfully",
"input_text": "Your input text result will appear here"
}

Responses:

Status CodeDescriptionContent-Type
200Successful Responseapplication/json
201Successful Creationapplication/json
400Bad Requestapplication/json
422Unprocessable Entityapplication/json
500Internal Server Errorapplication/json

Text to Image Generation API

/text-to-image/api/v1/text_to_image

  • Method: POST
  • Summary: Generate image for the provided input text
  • Description: The generated image can be customized by specifying the number of images to be generated, and the aspect ratio of the images.

Request Payload:

TypeParameterDescriptionData TypeIs Optional
Form Datauser_model_selectionAI model selection (dalle-3)StringNo
Form Datainput_typeInput textStringNo
Form Datanumber_of_imagesNumber of images to be generatedStringNo
Form Dataaspect_ratioAspect Ratio of imagesStringNo

Sample Code :

import requests

url = "https://api-genai-dev.learningmate.co/text-to-image/api/v1/text_to_image"
token = "your_token_here"

headers = {
"accept": "application/json",
"Authorization": f"Bearer {token}",
"Content-Type": "application/x-www-form-urlencoded",
}

data = {
"user_model_selection": "dall-e-3",
"input_text": """A paper craft art depicting a girl giving her cat a gentle hug. Both sit amidst potted plants, with the cat purring contentedly while the girl smiles. The scene is adorned with handcrafted paper flowers and leaves.""",
"number_of_images": "3",
"aspect_ratio": "1:1",
}

response = requests.post(url, headers=headers, data=data)

Example Response:

{
"status_code": 200,
"message": "SUCCESS::Text to Image generated successfully",
"images_created": {
"image_url_1": "Your image_url will appear here",
"image_url_2": "Your image_url will appear here",
"image_url_3": "Your image_url will appear here"
}
}

Responses:

Status CodeDescriptionContent-Type
200Successful Responseapplication/json
201Successful Creationapplication/json
400Bad Requestapplication/json
422Unprocessable Entityapplication/json
500Internal Server Errorapplication/json